#include "widget.h"
#include "ui_widget.h"
#include <QTimer>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QTimer* timer = new QTimer(this);
    connect(ui->pushButton,&QPushButton::clicked,[=]()
    {
       timer->start(1000);
    });

    connect(timer,&QTimer::timeout,[=]()
    {
        static int n = 1;
        ui->label->setText(QString::number(n++));
    });

    connect(ui->pushButton_2,&QPushButton::clicked,[=]()
    {
        timer->stop();
    });

    connect(ui->pushButton_3,&QPushButton::clicked,[=]()
    {
        qDebug() << ui->label->text();
    });
}

Widget::~Widget()
{
    delete ui;
}

